<?php

declare(strict_types=1);

namespace Core\Package\ElementPlus\FormCreate\FormItem;


/**
 * 未完成
 * Class Color
 */
class SelectMuliple extends FormItemAbstract
{
    protected string $_type = 'select';

    protected array $_options = [];


    /**
     * 获取值类型
     * @return string
     */
    public function valueType(): string
    {
        return self::VALUE_TYPE_ARRAY;
    }


    public function defaultProps(): array
    {
        return [
            'multiple' => true,
            'filterable' => true,
            'collapse-tags' => true,
            'multiple-limit' => 0,//最多可选数量,0为不限制
        ];
    }

    /**
     * Select constructor.
     * @param string $field
     * @param string $title
     * @param array $value
     */
    public function __construct(string $field, string $title, array $value = [])
    {
        $this->_title = $title;
        $this->_field = $field;
        $this->_value = $value;
    }


    /**
     * 设置数据
     * @param array $options
     * @return SelectMuliple
     */
    public function options(array $options): SelectMuliple
    {
        $this->_options = $options;
        return $this;
    }


    /**
     * 是否可过滤
     * @param bool $filterable
     * @return SelectMuliple
     */
    public function filterable(bool $filterable): SelectMuliple
    {
        return $this->props('filterable', $filterable);
    }

    /**
     * 输入提示
     * @param string $placeholder
     * @return SelectMuliple
     */
    public function placeholder(string $placeholder): SelectMuliple
    {
        return $this->props('placeholder', $placeholder);
    }

    /**
     * 最多可选数量
     * @param int $limit
     * @return SelectMuliple
     */
    public function multipleLimit(int $limit): SelectMuliple
    {
        return $this->props('multiple-limit', $limit);
    }
}